﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="mtaev_seisundid_seisund", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MtaevSeisundidSeisund))]
    public class MtaevSeisundidSeisundSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMtaevSeisundidSeisund clazz;
        
        public MtaevSeisundidSeisundSerializer(IMtaevSeisundidSeisund clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("rea_id");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.ReaId))).ToString());
            Writer.WriteEndElement();
            if (clazz.Ark!=null) {
                Writer.WriteStartElement("ark");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Ark))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.SeisId!=null) {
                Writer.WriteStartElement("seis_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SeisId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Sisu!=null) {
                Writer.WriteStartElement("sisu");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Sisu))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Periood!=null) {
                Writer.WriteStartElement("periood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Periood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PerioodiAlgusKpv!=null) {
                Writer.WriteStartElement("perioodi_algus_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.PerioodiAlgusKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PerioodiLoppKpv!=null) {
                Writer.WriteStartElement("perioodi_lopp_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.PerioodiLoppKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlgusKpv!=null) {
                Writer.WriteStartElement("algus_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.AlgusKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LoppKpv!=null) {
                Writer.WriteStartElement("lopp_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.LoppKpv))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="rea_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaev_seisundid_seisund>rea_id");
                }
                clazz.ReaId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("rea_id")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaev_seisundid_seisund>rea_id", Reader.LocalName);
            }
            if (Reader.LocalName=="ark") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaev_seisundid_seisund>ark");
                }
                clazz.Ark = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ark")).Value;
            }
            if (Reader.LocalName=="seis_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaev_seisundid_seisund>seis_id");
                }
                clazz.SeisId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("seis_id")).Value;
            }
            if (Reader.LocalName=="sisu") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaev_seisundid_seisund>sisu");
                }
                clazz.Sisu = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("sisu")).Value;
            }
            if (Reader.LocalName=="periood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaev_seisundid_seisund>periood");
                }
                clazz.Periood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("periood")).Value;
            }
            if (Reader.LocalName=="perioodi_algus_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaev_seisundid_seisund>perioodi_algus_kpv");
                }
                clazz.PerioodiAlgusKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("perioodi_algus_kpv")).Value;
            }
            if (Reader.LocalName=="perioodi_lopp_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaev_seisundid_seisund>perioodi_lopp_kpv");
                }
                clazz.PerioodiLoppKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("perioodi_lopp_kpv")).Value;
            }
            if (Reader.LocalName=="algus_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaev_seisundid_seisund>algus_kpv");
                }
                clazz.AlgusKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("algus_kpv")).Value;
            }
            if (Reader.LocalName=="lopp_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaev_seisundid_seisund>lopp_kpv");
                }
                clazz.LoppKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("lopp_kpv")).Value;
            }
        }
    }
}
